package cqrtplm.controller;

import com.github.pagehelper.PageInfo;
import com.ty.basic.response.ResponseResult;
import cqrtplm.constant.RouteConstant;
import cqrtplm.entity.ProblemJurisdictionDO;
import cqrtplm.service.RTProblemJurisdictionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author：lotus
 * @DATE: 2025/7/29 20:14
 */

@RestController
@Api(tags = "问题权限")
@RequestMapping(RouteConstant.ISSSUE + "v1")
public class RTProblemJurisdictionController {

    @Resource
    private RTProblemJurisdictionService rtProblemJurisdictionService;

    @GetMapping("/queryIssueAll")
    @ApiOperation(value = "查询所有问题权限", produces = "application/json; charset=utf-8")
    public ResponseResult<PageInfo<ProblemJurisdictionDO>> queryProblemJurisdictionAll(
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "20") int pageSize
    ) {

        return ResponseResult.success(rtProblemJurisdictionService.queryProblemJurisdictionAll(pageNum, pageSize));
    }

    @DeleteMapping("/deleteIssue")
    @ApiOperation(value = "根据oid删除", produces = "application/json; charset=utf-8")
    public ResponseResult<?> deleteProblemJurisdictionByOid(String oid) {

        rtProblemJurisdictionService.deleteProblemJurisdictionByOid(oid);

        return ResponseResult.success();
    }

    @PostMapping("/insertIssue")
    @ApiOperation(value = "插入权限", produces = "application/json; charset=utf-8")
    public ResponseResult<?> insertProblemJurisdiction(@RequestBody ProblemJurisdictionDO problemJurisdictionDO) {

        rtProblemJurisdictionService.insertProblemJurisdiction(problemJurisdictionDO);
        return ResponseResult.success();
    }


    @PostMapping("/updateIssue")
    @ApiOperation(value = "修改权限", produces = "application/json; charset=utf-8")
    public ResponseResult<?> updateProblemJurisdiction(@RequestBody ProblemJurisdictionDO problemJurisdictionDO) {

        rtProblemJurisdictionService.updateProblemJurisdiction(problemJurisdictionDO);
        return ResponseResult.success();
    }


    @GetMapping("/queryIssueTypeAndAttr")
    @ApiOperation(value = "查询问题类型和属性", produces = "application/json; charset=utf-8")
    public ResponseResult<Map<String,List<String>>> queryIssueTypeAndAttr() {
        Map<String,List<String>> issueMap=rtProblemJurisdictionService.queryIssueTypeAndAttr();
        return ResponseResult.success(issueMap);
    }



}
